package hu.fic.weddingstorefinder.map;

import java.util.ArrayList;

import android.graphics.drawable.Drawable;
import android.text.method.MovementMethod;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

public class StoreItemizedOverlay extends ItemizedOverlay<StoreOverlayItem> {
	
	private ArrayList<StoreOverlayItem> mOverlays = new ArrayList<StoreOverlayItem>();
	private StoreItemizedOverlayListener listener;
	
	public StoreItemizedOverlay(Drawable defaultMarker, StoreItemizedOverlayListener listener) {
		super(boundCenterBottom(defaultMarker));
		mOverlays = new ArrayList<StoreOverlayItem>();
		this.listener = listener;
	}

	@Override
	protected StoreOverlayItem createItem(int i) {
		// TODO Auto-generated method stub
		return mOverlays.get(i);
	}

	@Override
	public int size() {
		// TODO Auto-generated method stub
		return mOverlays.size();
	}
	
	public void removeAll() {
		// TODO Auto-generated method stub
		mOverlays.clear();
		populate();
	}
	
	public void addOverlay(StoreOverlayItem overlay) {
	    mOverlays.add(overlay);
	    populate();
	}

	@Override
	protected boolean onTap(int index) {
		listener.onTapToItem(mOverlays.get(index));
		return super.onTap(index);
	}
	

}
